package com.bwie.controller;

import com.bwie.pojo.TbType;
import com.bwie.service.TbTypeService;
import com.bwie.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @description :
 * @Author QiHainan
 * @Create 2025/6/23 13:49
 * @Version 1.0
 */
@RestController
@RequestMapping("/shop/type")
public class TypeController {
    @Autowired
    TbTypeService tbTypeService;

    /**
     * 获取商品分类分页列表
     * @return
     */
    @PostMapping("/getTreeList")
    public R getTreeList(){
        return tbTypeService.getTreeList();
    }

    /**
     * 添加类型
     * @param tbType
     * @return
     */
    @PostMapping("/addType")
    public R addType(@RequestBody @Validated TbType tbType){
        return tbTypeService.addType(tbType);
    }

    /**
     * 上传图片
     * @param file
     * @return
     */
    @PostMapping("/uploadImage")
    public R uploadImage(@RequestPart("file") MultipartFile file){
        return tbTypeService.uploadImage(file);
    }

    /**
     * 获取商品分类树形数据
     * @return
     */
    @PostMapping("/getSelectTree")
    public R getSelectTree(){
        return tbTypeService.getSelectTree();
    }
}
